<?php 
session_start();

if(!isset($_SESSION['username']))
{
	header("Location: ../login.php");
	exit();
}

require("../db/opendb.php");
require("../rss/rss_insert.php");

$_SESSION["username"];
$query = "select * from Users where Username='".$_SESSION["username"]."'";
$result = mysql_query($query) or die ("SQL Error".mysql_error());
$row=mysql_fetch_assoc($result);

if (isset($_GET["url"]))
{
	
	$message="";
	$bool = false;

	//does the blog already exist
	$sql = "Select Url from Blog_Feeds where Url = '".$_GET['url']."'";
	$result = mysql_query($sql) or die ("SQL Error".mysql_error());
	$num = mysql_num_rows($result);

	if($num < 1)
	{

		$message = Submit_Articles($_GET['url'], $insert_id, $_GET['tags'], $_GET['category'], $_GET['lat'], $_GET['lng'], $_GET['city'], $_GET['state']);
		//$message .= " <img src=../images/rss_go.gif align='absmiddle'> <a href=blogs.php>View your blogs</a>";
//		echo "<meta http-equiv=refresh content=0;URL=blog.php>";
	}
	else
	{
		$message = "The blog feed already exists.";
		echo "<meta http-equiv=refresh content=0;URL=blog.php?page=add&message=".$message.">";
	}

	if($message =="")
	{
		$message = "There was a problem with the feed.";
		echo "<meta http-equiv=refresh content=0;URL=blog.php?page=add&message=".$message.">";

	}

}


?>
